package com.wangcang.widgetlibrary.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.wangcang.widgetlibrary.R;
import com.wangcang.widgetlibrary.slider.RangeBar;

import java.util.List;

/**
 * @author : mundane
 * @time : 2017/9/22 16:15
 * @description :
 * @file : TestSlidebarLvAdapter.java
 */

public class TestSlidebarLvAdapter extends BaseAdapter {

	private List<String> mDataList;

	public TestSlidebarLvAdapter(List<String> dataList) {
		mDataList = dataList;
	}

	@Override
	public int getCount() {
		return mDataList == null ? 0 : mDataList.size();
	}

	@Override
	public String getItem(int position) {
		return mDataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_test_slidebar, parent, false);
			holder = new ViewHolder(convertView);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		String data = mDataList.get(position);
		//	process data
		holder.mRangeBar.setProgress(20);

		return convertView;
	}

	static class ViewHolder {

		public RangeBar mRangeBar;

		public ViewHolder(View convertView) {
			// findView
			mRangeBar = (RangeBar) convertView.findViewById(R.id.custom_rangebar);
		}
	}

}
